<template>
    <div id="parts">
        <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="taskcode" label="机器条码" sortable min-width="160"></el-table-column>
            <el-table-column prop="batchnums" label="生产批号" sortable min-width="160"></el-table-column>
            <el-table-column prop="resourcenameName" label="机器名称" sortable min-width="130"></el-table-column>
            <el-table-column prop="typenums" label="产品型号" sortable min-width="110"></el-table-column>
            <el-table-column prop="taskreleaseaddtime" label="任务创建时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskstartorendtime" label="任务需完成时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="istaskstart" label="任务是否接收" :formatter="formatNeedTrain" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskbegintime" label="打包开始时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskendtime" label="打包结束时间" sortable min-width="160"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="dataList.length"></el-pagination>

        <!-- 详情信息 -->
        <el-dialog :title="dialogTitle" width="85%" top="30px" :visible.sync="isDialog" :close-on-click-modal="false" >
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;">
                <el-tab-pane label="任务信息" name="1" class="dialog1" :style="dialogHeightPane" >
                    <h3 class="dialog-plate-title"><span>基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="新机器条码"><el-input v-model="dialogList.taskcode" :disabled="!dialogListDisabled.taskcode"></el-input></el-form-item>
                        <el-form-item label="生产批号"><el-input v-model="dialogList.batchnums" :disabled="!dialogListDisabled.batchnums"></el-input></el-form-item>
                        <el-form-item label="机器名称"><el-input  v-model="dialogList.resourcenameName" :disabled="!dialogListDisabled.resourcenameName"></el-input></el-form-item>
                        <el-form-item label="产品型号"><el-input v-model="dialogList.typenums" :disabled="!dialogListDisabled.typenums"></el-input></el-form-item>
                        <el-form-item label="业务类型"><el-input v-model="dialogList.businesstype" :disabled="!dialogListDisabled.businesstype"></el-input></el-form-item>
                        <el-form-item label="任务创建人"><el-input v-model="dialogList.taskreleasepersonName" :disabled="!dialogListDisabled.taskreleasepersonName"></el-input></el-form-item>
                        <el-form-item label="任务创建时间"><el-date-picker v-model="dialogList.taskreleaseaddtime" :disabled="!dialogListDisabled.taskreleaseaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                        <el-form-item label="打包任务负责人">
                            <el-select v-model="dialogList.taskperformperson" :disabled="!dialogListDisabled.taskperformperson">
                                <el-option v-for="item in materialManagers" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="任务需完成时间">
                            <el-date-picker v-model="dialogList.taskstartorendtime" :disabled="!dialogListDisabled.taskstartorendtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="计划创建类型">
                            <el-select v-model="dialogList.tasktype" :disabled="!dialogListDisabled.tasktype">
                                <el-option label="计划任务" :value="1"></el-option>
                                <el-option label="临时任务" :value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>待办信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务是否接收">
                            <el-select v-model="dialogList.istaskstart" :disabled="!dialogListDisabled.istaskstart">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="接收创建时间">
                            <el-date-picker v-model="dialogList.taskstartaddtime" :disabled="!dialogListDisabled.taskstartaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>进行中信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="打包是否开始">
                            <el-select v-model="dialogList.istaskbegin" :disabled="!dialogListDisabled.istaskbegin">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="打包开始时间">
                            <el-date-picker v-model="dialogList.taskbegintime" :disabled="!dialogListDisabled.taskbegintime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="启动创建时间">
                            <el-date-picker v-model="dialogList.taskbeginaddtime" :disabled="!dialogListDisabled.taskbeginaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="打包是否结束">
                            <el-select v-model="dialogList.istaskend" :disabled="!dialogListDisabled.istaskend">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="打包结束时间">
                            <el-date-picker v-model="dialogList.taskendtime" :disabled="!dialogListDisabled.taskendtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="结束创建时间">
                            <el-date-picker v-model="dialogList.taskendaddtime" :disabled="!dialogListDisabled.taskendaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>复核信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务是否复核">
                            <el-select v-model="dialogList.isreviewtask" :disabled="!dialogListDisabled.isreviewtask">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核执行人">
                            <el-input v-model="dialogList.reviewpersonName" :disabled="!dialogListDisabled.reviewpersonName"></el-input>
                        </el-form-item>
                        <el-form-item label="复核结果">
                            <el-select v-model="dialogList.reviewresult" :disabled="!dialogListDisabled.reviewresult">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="正常" value="1"></el-option>
                                <el-option label="异常" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核时间">
                            <el-date-picker v-model="dialogList.reviewtime" :disabled="!dialogListDisabled.reviewtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="复核创建时间">
                            <el-date-picker v-model="dialogList.reviewaddtime" :disabled="!dialogListDisabled.reviewaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>
                    <div style="text-align: right">
                        <el-button @click="submitList" type="primary">确 定</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane  label="过程状态信息" name="2" :style="dialogHeightPane">
                    <el-button @click="insertProcessStateList" type="primary" size="small">新增</el-button>
                    <el-table :data="processStateData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="name" label="消耗物料名称" sortable min-width="150"></el-table-column>
                        <el-table-column prop="batchnums" label="消耗物料批号" sortable min-width="150"></el-table-column>
                        <el-table-column prop="typenums" label="消耗物料型号" sortable min-width="150"></el-table-column>
                        <el-table-column prop="nums" label="消耗数量" sortable min-width="100"></el-table-column>
                        <el-table-column prop="unit" label="单位" sortable min-width="90"></el-table-column>
                        <el-table-column prop="userName" label="使用人" sortable min-width="90"></el-table-column>
                        <el-table-column prop="usertime" label="使用时间" sortable min-width="160"></el-table-column>
                        <el-table-column prop="createtime" label="创建时间" sortable min-width="160"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="updateProcessStateList(scope.row)" type="text" size="small">编辑</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="processStateData.length"></el-pagination>
                </el-tab-pane>
                <el-tab-pane label="备注记录信息" name="3" :style="dialogHeightPane">
                    <el-button @click="insertNotesRecordList" type="primary" size="small">新增</el-button>
                    <el-table :data="notesRecordData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="personName" label="检测人" sortable min-width="110"></el-table-column>
                        <el-table-column prop="type" label="检测部件名称" sortable min-width="110"></el-table-column>
                        <el-table-column prop="object" label="检测结果" sortable min-width="110"></el-table-column>
                        <el-table-column prop="time" label="检测创建时间" sortable min-width="160"></el-table-column>
                        <el-table-column prop="content" label="检测内容说明" sortable min-width="250"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="updateNotesRecordList(scope.row)" type="text" size="small">编辑</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="notesRecordData.length"></el-pagination>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>

        <!-- 过程状态信息 -->
        <el-dialog :title="dialogProcessStateTitle" width="900px" center :visible.sync="isProcessStateDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogProcessStateList" label-position="right" label-width="180px">
                <el-form-item label="消耗物料名称"><el-input v-model="dialogProcessStateList.name"></el-input></el-form-item>
                <el-form-item label="消耗物料批号"><el-input v-model="dialogProcessStateList.batchnums"></el-input></el-form-item>
                <el-form-item label="消耗物料型号"><el-input v-model="dialogProcessStateList.typenums"></el-input></el-form-item>
                <el-form-item label="消耗数量"><el-input v-model="dialogProcessStateList.nums"></el-input></el-form-item>
                <el-form-item label="单位"><el-input v-model="dialogProcessStateList.unit"></el-input></el-form-item>
                <el-form-item label="使用人"><el-input v-model="dialogProcessStateList.userName" disabled></el-input></el-form-item>
                <el-form-item label="使用时间"><el-date-picker v-model="dialogProcessStateList.usertime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                <el-form-item label="创建时间"><el-input v-model="dialogProcessStateList.createtime" disabled></el-input></el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
                <el-button @click="submitProcessStateList" type="primary">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 备注记录信息 -->
        <el-dialog :title="dialogNotesRecordTitle" width="600px" center :visible.sync="isNotesRecordDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogNotesRecordList" label-position="right" label-width="180px">
                <el-form-item label="检测人"><el-input v-model="dialogNotesRecordList.personName" disabled></el-input></el-form-item>
                <el-form-item label="检测创建时间"><el-input v-model="dialogNotesRecordList.time" disabled></el-input></el-form-item>
                <el-form-item label="检测部件名称"><el-input v-model="dialogNotesRecordList.type" ></el-input></el-form-item>
                <el-form-item label="检测结果"><el-input v-model="dialogNotesRecordList.object"></el-input></el-form-item>
                <el-form-item label="检测内容说明"><el-input type="textarea" :rows="8"  v-model="dialogNotesRecordList.content" style="width: 355px;"></el-input></el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
                <el-button @click="submitNotesRecordList" type="primary">确 定</el-button>
            </div>
        </el-dialog>

    </div>
</template>

<script>
    export default {
        name: "",
        data() {
            let token = sessionStorage.getItem("tokenId");
            let menuId = sessionStorage.getItem('menuId');
            return {
                tokenId: token,
                menuId:menuId,
                currentPage: 1,
                pagesize: 10,
                activeName: '1',
                materialManagers:[],
                tableHeight: document.documentElement.clientHeight - 135,
                dataList: [],

                //基本信息
                isDialog: false,
                dialogTitle: '',
                dialogHeightPane: {
                    height: (document.documentElement.clientHeight - 180) + 'px',
                    overflowY: 'auto'
                },
                dialogTableHeight: document.documentElement.clientHeight - 260,
                dialogList:{
                    actualcompletenums: "",
                    batchnums: "",
                    businesstype: "",
                    isreviewtask: "",
                    istaskbegin: "",
                    istaskend: "",
                    istaskstart: "",
                    resourcename: "",
                    resourcenameName: "",
                    reviewaddtime: "",
                    reviewperson: "",
                    reviewpersonName: "",
                    reviewresult: "",
                    reviewtime: "",
                    taskbeginaddtime: "",
                    taskbegintime: "",
                    taskcode: "",
                    taskendaddtime: "",
                    taskendtime: "",
                    taskfinishstate: "",
                    tasknums: "",
                    taskperformperson: "",
                    taskperformpersonName: "",
                    taskreleaseaddtime: "",
                    taskreleaseperson: "",
                    taskreleasepersonName: "",
                    taskstartaddtime: "",
                    taskstartorendtime: "",
                    taskstate: "",
                    tasktype: "",
                    tid: "",
                    typenums: "",
                },
                dialogListDisabled:{
                    taskcode: true,
                    batchnums: true,
                    resourcename: true,
                    resourcenameName: true,
                    typenums: true,
                    businesstype: true,
                    taskreleaseperson: true,
                    taskreleasepersonName: true,
                    taskreleaseaddtime: true,
                    taskperformperson: true,
                    taskperformpersonName: true,
                    taskstartorendtime: true,
                    tasktype: true,
                    istaskstart: true,
                    taskstartaddtime: true,
                    istaskbegin: true,
                    taskbegintime: true,
                    taskbeginaddtime: true,
                    istaskend: true,
                    taskendtime: true,
                    taskendaddtime: true,
                    isreviewtask: true,
                    reviewperson: true,
                    reviewpersonName: true,
                    reviewresult: true,
                    reviewtime: true,
                    reviewaddtime: true,

                    actualcompletenums: true,
                    taskfinishstate: true,
                    tasknums: true,
                    taskstate: true,
                    tid: true,
                },

                //过程状态信息
                isProcessStateDialog: false,
                dialogProcessStateTitle: '',
                dialogProcessStateList:{
                    batchnums: '',
                    createtime: '',
                    id: '',
                    name: '',
                    nums: '',
                    tid: '',
                    typenums: '',
                    unit: '',
                    user: '',
                    userName: '',
                    usertime:'',
                },
                processStateData:[],

                //备注记录信息
                dialogNotesRecordURL: {
                    getURL: '/api/adscm/operation/jqdbMachinepackinginfo/selectByTid/',
                    insertURL: '/api/adscm/operation/jqdbMachinepackinginfo/insert',
                    updateURL: '/api/adscm/operation/jqdbMachinepackinginfo/update',
                },
                isNotesRecordDialog: false,
                dialogNotesRecordTitle: '',
                dialogNotesRecordList:{
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    tid: '',
                    time: '',
                    type: '',
                },
                notesRecordData:[],
            };
        },
        created() {
            this.getData();
            this.getMaterialManagersData();
        },
        methods: {
            getMaterialManagersData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/jqlhMachineaging/selectTaskPerformPerson?tokenId='+_this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.materialManagers = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getData() {
                let _this = this;
                let loading = this.$loading({
                    target: document.querySelector(".wrapper > .content-box"),
                    lock: true,
                    text: '正在努力加载中...',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.8)'
                });
                let id;
                if (_this.menuId==='4576') {
                    id = '0/0/0';
                } else if (_this.menuId==='4577') {
                    id = '1/0/0';
                }else if (_this.menuId==='4578') {
                    id = '1/1/0';
                }else if (_this.menuId==='4579') {
                    id = '1/1/1';
                }
                this.$http({
                    url: '/api/adscm/operation/jqdbMachinepacking/selectJqdbMachinepacking/'+id+'?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.dataList = res.data.content;
                        loading.close();
                    } else {
                        _this.$message.error(res.data.desc);
                        loading.close();
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    loading.close();
                })
            },
            updateList(row) {
                this.isDialog = true;
                this.activeName = '1';
                this.dialogListDisabled={
                    taskcode:false,
                    batchnums: this.menuId==='4576' ? true : false,
                    resourcename: false,
                    resourcenameName: false,
                    typenums:this.menuId==='4576' ? true : false,
                    businesstype:this.menuId==='4576' ? true : false,
                    taskreleaseperson:false,
                    taskreleasepersonName:false,
                    taskreleaseaddtime:false,
                    taskperformperson:this.menuId==='4576' ? true : false,
                    taskperformpersonName:this.menuId==='4576' ? true : false,
                    taskstartorendtime:this.menuId==='4576' ? true : false,
                    tasktype:this.menuId==='4576' ? true : false,
                    istaskstart:this.menuId==='4576' ? true : false,
                    taskstartaddtime:false,
                    istaskbegin:this.menuId==='4577' ? true : false,
                    taskbegintime:this.menuId==='4577' ? true : false,
                    taskbeginaddtime:false,
                    istaskend:this.menuId==='4577' ? true : false,
                    taskendtime:this.menuId==='4577' ? true : false,
                    taskendaddtime:false,
                    isreviewtask:this.menuId==='4578' ? true : false,
                    reviewperson:false,
                    reviewpersonName:false,
                    reviewresult:this.menuId==='4578' ? true : false,
                    reviewtime:this.menuId==='4578' ? true : false,
                    reviewaddtime:false,
                    tasknums:false,
                    actualcompletenums:false,
                    taskfinishstate:false,
                    taskstate:false,
                    tid:false,
                };
                this.dialogList = row;
                this.dialogList.taskperformperson = this.dialogList.taskperformperson ? parseInt(this.dialogList.taskperformperson) : "";
            },
            submitList(){
                let _this = this;
                _this.dialogList.taskstartorendtime = _this.timestampToTime( _this.dialogList.taskstartorendtime);
                _this.dialogList.taskbegintime = _this.timestampToTime( _this.dialogList.taskbegintime);
                _this.dialogList.taskendtime = _this.timestampToTime( _this.dialogList.taskendtime);
                _this.dialogList.reviewtime = _this.timestampToTime( _this.dialogList.reviewtime);
                this.$http({
                    url: '/api/adscm/operation/jqdbMachinepacking/update?tokenId='+_this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data:_this.dialogList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isDialog = false;
                        _this.getData()
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            //过程状态信息
            getProcessStateData()  {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/jqdbMachinepackingdetail/selectByTid/'+_this.dialogList.tid+'?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.processStateData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertProcessStateList(){
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '添加';
                this.dialogProcessStateList={
                    batchnums: '',
                    createtime: '',
                    id: '',
                    name: '',
                    nums: '',
                    typenums: '',
                    unit: '',
                    user: '',
                    userName: '',
                    usertime:'',
                    tid: this.dialogList.tid,
                };
            },
            updateProcessStateList(row) {
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '编辑';
                this.dialogProcessStateList = row;
            },
            submitProcessStateList(){
                let _this = this;
                let url;
                if (_this.dialogProcessStateTitle==='添加') {
                    url = '/api/adscm/operation/jqdbMachinepackingdetail/insert?tokenId='+_this.tokenId;
                } else if (_this.dialogProcessStateTitle==='编辑') {
                    url = '/api/adscm/operation/jqdbMachinepackingdetail/update?tokenId='+_this.tokenId;
                }
                _this.dialogProcessStateList.usertime = this.timestampToTime(_this.dialogProcessStateList.usertime);

                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data:_this.dialogProcessStateList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isProcessStateDialog = false;
                        if (_this.dialogProcessStateTitle==='添加') _this.getProcessStateData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            //备注记录信息
            getNotesRecordData() {
                let _this = this;
                this.$http({
                    url: _this.dialogNotesRecordURL.getURL + _this.dialogList.tid + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.notesRecordData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertNotesRecordList() {
                this.isNotesRecordDialog = true;
                this.dialogNotesRecordTitle = '添加';
                this.dialogNotesRecordList = {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    time: '',
                    type: '',
                    tid: this.dialogList.tid,
                };
            },
            updateNotesRecordList(row) {
                this.isNotesRecordDialog = true;
                this.dialogNotesRecordTitle = '编辑';
                this.dialogNotesRecordList = row;
            },
            submitNotesRecordList() {
                let _this = this;
                let url;
                if (_this.dialogNotesRecordTitle === '添加') {
                    url = _this.dialogNotesRecordURL.insertURL + '?tokenId=' + _this.tokenId;
                } else if (_this.dialogNotesRecordTitle === '编辑') {
                    url = _this.dialogNotesRecordURL.updateURL + '?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogNotesRecordList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isNotesRecordDialog = false;
                        if (_this.dialogNotesRecordTitle === '添加') _this.getNotesRecordData();
                            } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },


            handleClick(tab, event) {
                if(tab.name==='2'){
                    this.getProcessStateData();
                } else if(tab.name==='3'){
                    this.getNotesRecordData();
                }

            },
            handleSizeChange: function (size) {
                this.pagesize = size;
            },
            handleCurrentChange: function (currentPage) {
                this.currentPage = currentPage;
            },
            timestampToTime(timestamp) {
                if (timestamp) {
                    let date = new Date(timestamp);
                    let Y = date.getFullYear() + '-';
                    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                    return timestamp ? Y + M + D + h + m + '00' : '';
                } else {
                    return '';
                }
            },
        }
    }
</script>

<style scoped>

    #parts .el-table--small {
        font-size: 13px;
    }

    #parts .el-table .cell,
    #parts .el-table th div {
        padding-left: 0;
        padding-right: 0;
    }

    #parts .el-tab-pane.dialog1 .el-form{
        margin-bottom: 30px;
    }

</style>
